import java.util.Vector;
import javax.swing.table.AbstractTableModel;


public class TableModelPeers extends AbstractTableModel {

	private String [] columnNames = {"File Name","Hash value","Peer address","Finished"};
	private Vector <Peer> peerList;

	public TableModelPeers (Vector peersVector){
		super();
		this.peerList=peersVector;
	}
	
	public int getColumnCount(){
		return this.columnNames.length;
	}
	
	public int getRowCount(){
		return this.peerList.size();
	}
	
	public void setValueAt(Object value, int row, int col){
		Peer tempPeer = this.peerList.get(row);
		switch (col){
		case 0:
			tempPeer.setFileName((String) value);
			break;
		case 1:
			tempPeer.setHashValue((String)value);
			break;
		case 2:
			tempPeer.setIpAddress((String) value);
			break;
		case 3:
			tempPeer.setIsFinished((String) value);
			break;
			
		}
	}

	public String getColumnName (int col){
		return this.columnNames[col];
	}
	
	public Object getValueAt(int row, int col){
		Peer tempPeer = this.peerList.elementAt(row);
		switch (col){
	case 0:
		return tempPeer.getFileName();
	case 1:
		return tempPeer.getHashValue();
	case 2:
		return tempPeer.getIpAddress();
		
	case 3:
		return tempPeer.getIsFinished();
		
	}
		return null;
	}
}
